package org.platform.core.filecommand;

import org.platform.tool.helper.ResourceHelper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import javax.annotation.PostConstruct;

/**
 * 文件监听初始化
 *
 * @author FengJie
 * @date 2018/8/3
 */
@Component
public class FileListenerInit {

    @Autowired
    ResourceHelper resource;

    @PostConstruct
    void init() {
        String host = resource.getFtpIp();
        int port = resource.getFtpPort();
        String username = resource.getPtpUsername();
        String password = resource.getPtpPassword();
        String[] backDirName = {resource.getFtpBakboxDir()};
        String[] remoteDirNames = {resource.getFtpRecvDir()};
        String indexDirName = resource.getLocalRootDir() + resource.getLocalArchivingDir();
        String[] suffixNames = {".xml"};
        FtpWatchJob ftpWatch = new FtpWatchJob(host, port, username, password, remoteDirNames, backDirName, indexDirName, suffixNames);
        ftpWatch.start();
    }
}
